﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using mborn.BLL;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void BttEnter_Click(object sender, EventArgs e)
    {
        UserBLL bll = new UserBLL();
        bool isLogin=false ;
        string strMail = txtMail.Text;

        isLogin  = bll.IsUserCanLogin(txtMail.Text, txtPassword.Text);
        if (isLogin == true)
        {
            HttpCookie acookie = new HttpCookie("Email");
            HttpCookie bcookie = new HttpCookie("ID");

            acookie.Value = txtMail.Text;
            bcookie.Value = bll.GetUserIDByEmail(strMail);


            Response.Cookies.Add(acookie);
            Response.Cookies.Add(bcookie);

            Response.Redirect("Default.aspx");
        }
        else 
        {
            cvLogin.ErrorMessage = "用户名或密码错误，不能登录";
            cvLogin.IsValid = false;
        }

    }
}
